fix(oxlint): Skip vite.config.ts w/o .lint field in auto-discovery#20255
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
vite.config.ts w/o .lint field in auto-discovery
2308d45 to
079cd61
Compare
e58c283 to
2f76cfd
Compare
There was a problem hiding this comment.
Pull request overview
Updates oxlint’s config auto-discovery so that a vite.config.ts without a .lint field is treated as “not an oxlint config” (skip and continue searching), while keeping explicit --config vite.config.ts behavior as an error.
Changes:
- Add
try_load_root_vite_configto skip auto-discoveredvite.config.tswhen.lintis missing and continue ancestor search. - Add/adjust CLI fixture coverage for both auto-discovery skip and explicit
--configerror behavior. - Add an LSP fixture verifying that a child
vite.config.tswithout.lintdoesn’t block finding a parent.oxlintrc.json.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| apps/oxlint/src/config_loader.rs | Implements vite-config auto-discovery skipping logic via try_load_root_vite_config. |
| apps/oxlint/src/js_config.rs | Documents the diagnostic string relied upon for vite-config skip detection. |
| apps/oxlint/test/lsp/lint/lint.test.ts | Adds a new LSP fixture case to the parameterized config test matrix. |
| apps/oxlint/test/lsp/lint/snapshots/lint.test.ts.snap | Snapshot for the new LSP fixture diagnostics. |
| apps/oxlint/test/lsp/lint/fixtures/vite-config-skip-finds-parent/.oxlintrc.json | Parent config used to prove ancestor search continues past a non-oxlint vite config. |
| apps/oxlint/test/lsp/lint/fixtures/vite-config-skip-finds-parent/child/vite.config.ts | Child vite config missing .lint to trigger the skip behavior. |
| apps/oxlint/test/lsp/lint/fixtures/vite-config-skip-finds-parent/child/test.js | Lint target verifying parent config is applied. |
| apps/oxlint/test/fixtures/vite_config_no_lint_field/output.snap.md | Updates expected CLI behavior for auto-discovery (no longer fails on missing .lint). |
| apps/oxlint/test/fixtures/vite_config_explicit_no_lint_field/vite.config.ts | Adds explicit-config fixture vite file missing .lint. |
| apps/oxlint/test/fixtures/vite_config_explicit_no_lint_field/options.json | Runs oxlint with --config vite.config.ts to assert error behavior. |
| apps/oxlint/test/fixtures/vite_config_explicit_no_lint_field/files/test.js | Lint target for the explicit-config fixture. |
| apps/oxlint/test/fixtures/vite_config_explicit_no_lint_field/output.snap.md | Snapshot asserting explicit --config still errors on missing .lint. |
Comments suppressed due to low confidence (1)
apps/oxlint/src/js_config.rs:137
- The new coupling note here makes
parse_js_config_responseresponsible for keeping an exact error string stable for config auto-discovery. To reduce long-term maintenance risk, consider tagging this diagnostic with an explicitOxcDiagnosticerror code (e.g.with_error_code("oxlint", "missing_vite_lint_field")) soConfigLoadercan reliably identify and skip this specific condition without depending on the message text.
// NOTE: This error message is shown to users (explicit `--config`) and also
// matched by `try_load_root_vite_config` in config_loader.rs (auto-discovery skip).
errors.push(OxcDiagnostic::error(format!(
"Expected a `{VITE_OXLINT_CONFIG_FIELD}` field in the default export of {}",
entry.path
)));
You can also share your feedback on Copilot code review. Take the survey.
Merge activity
|
079cd61 to
11a2b45
Compare
2f76cfd to
cc89dbf
Compare
# Oxlint ### 🐛 Bug Fixes - 4ea67de oxlint,oxfmt: Skip `vite.config.ts` exports `defineConfig(fn)` (#20260) (leaysgur) - cc89dbf oxlint: Skip `vite.config.ts` w/o `.lint` field in auto-discovery (#20255) (leaysgur) - 89b7ca9 linter/no-duplicate-imports: Only check aggregated exports (#20178) (kennytm) - 691f556 linter/explicit-module-boundary-types: Ignore constructor callbacks (#20221) (camc314) ### ⚡ Performance - d160dca linter/plugins: Reduce array lookups in visitor compilation (#20249) (overlookmotel) ### 📚 Documentation - 0c7da4f linter: Fix extra closing brace in example config. (#20253) (connorshea) - 13606c3 linter/plugins: Update conformance README (#20234) (overlookmotel) # Oxfmt ### 🐛 Bug Fixes - 4ea67de oxlint,oxfmt: Skip `vite.config.ts` exports `defineConfig(fn)` (#20260) (leaysgur) - 11a2b45 oxfmt: Skip `vite.config.ts` w/o `.fmt` field in auto-discovery (#20254) (leaysgur) Co-authored-by: leaysgur <6259812+leaysgur@users.noreply.github.com>

The same as #20254 for Oxlint.
The refactoring to move the logic to the JS side is being addressed in a subsequent PR. (Copilot review will be also addressed)